/*
 * Reg_BitBand.h
 *
 *  Created on: 2020年7月21日
 *      Author: ou235
 */

#ifndef USER_INC_REG_BITBAND_H_
#define USER_INC_REG_BITBAND_H_

#include <stdint.h>

/*----------------------------[寄存器位定义与操作]----------------------------*/

#define bit(X)  (1<<X)

uint32_t range(uint32_t i, uint32_t j);
void Reg(volatile uint32_t * p, uint32_t range, uint32_t set);

/*----------------------------[GPIO与位带]----------------------------*/

#define PAo(X) *((volatile uint32_t *)(0x42000000+(GPIOA_BASE+0x14-0x40000000)*32+4*X))     //  PCo(13)=0;
#define PBo(X) *((volatile uint32_t *)(0x42000000+(GPIOB_BASE+0x14-0x40000000)*32+4*X))
#define PCo(X) *((volatile uint32_t *)(0x42000000+(GPIOC_BASE+0x14-0x40000000)*32+4*X))
#define PDo(X) *((volatile uint32_t *)(0x42000000+(GPIOD_BASE+0x14-0x40000000)*32+4*X))
#define PEo(X) *((volatile uint32_t *)(0x42000000+(GPIOE_BASE+0x14-0x40000000)*32+4*X))
#define PFo(X) *((volatile uint32_t *)(0x42000000+(GPIOF_BASE+0x14-0x40000000)*32+4*X))
#define PGo(X) *((volatile uint32_t *)(0x42000000+(GPIOG_BASE+0x14-0x40000000)*32+4*X))
#define PHo(X) *((volatile uint32_t *)(0x42000000+(GPIOH_BASE+0x14-0x40000000)*32+4*X))
#define PIo(X) *((volatile uint32_t *)(0x42000000+(GPIOI_BASE+0x14-0x40000000)*32+4*X))

#define PAi(X) *((volatile uint32_t *)(0x42000000+(GPIOA_BASE+0x10-0x40000000)*32+4*X))
#define PBi(X) *((volatile uint32_t *)(0x42000000+(GPIOB_BASE+0x10-0x40000000)*32+4*X))
#define PCi(X) *((volatile uint32_t *)(0x42000000+(GPIOC_BASE+0x10-0x40000000)*32+4*X))
#define PDi(X) *((volatile uint32_t *)(0x42000000+(GPIOD_BASE+0x10-0x40000000)*32+4*X))
#define PEi(X) *((volatile uint32_t *)(0x42000000+(GPIOE_BASE+0x10-0x40000000)*32+4*X))
#define PFi(X) *((volatile uint32_t *)(0x42000000+(GPIOF_BASE+0x10-0x40000000)*32+4*X))
#define PGi(X) *((volatile uint32_t *)(0x42000000+(GPIOG_BASE+0x10-0x40000000)*32+4*X))
#define PHi(X) *((volatile uint32_t *)(0x42000000+(GPIOH_BASE+0x10-0x40000000)*32+4*X))
#define PIi(X) *((volatile uint32_t *)(0x42000000+(GPIOI_BASE+0x10-0x40000000)*32+4*X))

volatile uint32_t * Bit(volatile uint32_t * p, uint32_t X);

#define Bit(p,X) (*Bit(p,X))      //  Bit(&PC->ODR,13)=0;


#endif /* USER_INC_REG_BITBAND_H_ */
